const {exec} = require('child_process')

//在 Windows 平台上通过 wmic 命令获取设备的 UUID（通用唯一识别码）
function getUUID(){
    return new Promise((resolve, reject) => {
        exec('wmic csproduct get uuid', (error, stdout, stderr) => {
            if (error) {
                reject(`Error: ${error.message}`);
            } else if (stderr) {
                reject(`Error: ${stderr}`);
            } else {
                console.log(stdout.split('\n'))

                console.log(stdout.split('\n')[1])
                const uuid = stdout.split('\n')[1].trim();
                resolve(uuid);
            }
        });
    });
}


//windows获取mac地址
function getMacAddress(){
    return new Promise((resolve, reject) => {
        exec('wmic nic get MACAddress', (error, stdout, stderr) => {
            if (error) {
                reject(`Error: ${error.message}`);
            } else if (stderr) {
                reject(`Error: ${stderr}`);
            } else {
                console.log(stdout.split('\n'))

                console.log(stdout.split('\n')[1])
                const uuid = stdout.split('\n')[1].trim();
                resolve(uuid);
            }
        });
    });
}

export {
    getUUID,
    getMacAddress
}




